/* AI弹窗样式 */
.ai-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(5px);
}

.ai-modal-container {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: aiModalSlideIn 0.3s ease-out;
}

@keyframes aiModalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* 弹窗头部 */
.ai-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px 16px;
  border-bottom: 1px solid #f0f0f0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.ai-modal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 600;
}

.ai-icon {
  font-size: 20px;
}

.ai-modal-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 16px;
}

.ai-modal-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* 原始消息显示 */
.ai-modal-original-message {
  padding: 16px 24px;
  background: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.original-message-section {
  flex: 1;
}

.streaming-controls-section {
  flex-shrink: 0;
  min-width: 120px;
}

.streaming-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.original-message-label {
  font-size: 14px;
  color: #666;
  margin-bottom: 8px;
  font-weight: 500;
}

.original-message-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.message-type-tag {
  background: #667eea;
  color: white;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.message-text {
  color: #333;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

/* AI回答内容区域 */
.ai-modal-content {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  min-height: 200px;
}

/* 加载状态 */
.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.ai-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #667eea;
  border-radius: 50%;
  animation: aiSpinner 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes aiSpinner {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.ai-loading-text {
  color: #666;
  font-size: 16px;
  font-weight: 500;
}

/* 错误状态 */
.ai-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.ai-error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.ai-error-text {
  color: #666;
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.ai-retry-btn {
  background: #667eea;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.ai-retry-btn:hover {
  background: #5a6fd8;
  transform: translateY(-1px);
}

/* AI回答内容 */
.ai-response {
  animation: aiResponseFadeIn 0.5s ease-out;
}

@keyframes aiResponseFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-response-content {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  border-left: 4px solid #667eea;
}

.ai-response-line {
  margin: 0 0 12px 0;
  color: #333;
  font-size: 14px;
  line-height: 1.6;
}

.ai-response-line:last-child {
  margin-bottom: 0;
}

/* AI回答操作按钮 */
.ai-response-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* 流式输出样式 */
.streaming-content {
  position: relative;
  display: inline-block;
}

.streaming-cursor {
  animation: blink 1s infinite;
  color: #007bff;
  font-weight: bold;
  margin-left: 2px;
}

@keyframes blink {
  0%,
  50% {
    opacity: 1;
  }
  51%,
  100% {
    opacity: 0;
  }
}

/* 流式输出控制按钮样式 */
.ai-pause-btn,
.ai-stop-btn {
  background: linear-gradient(135deg, #ff6b6b, #ee5a52);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 6px rgba(255, 107, 107, 0.3);
  width: 80px;
  text-align: center;
}

.ai-pause-btn:hover,
.ai-stop-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(255, 107, 107, 0.4);
}

.ai-pause-btn:active,
.ai-stop-btn:active {
  transform: translateY(0);
}

.ai-pause-btn {
  background: linear-gradient(135deg, #ffa726, #ff9800);
  box-shadow: 0 2px 6px rgba(255, 167, 38, 0.3);
}

.ai-pause-btn:hover {
  box-shadow: 0 3px 8px rgba(255, 167, 38, 0.4);
}

.ai-copy-btn,
.ai-regenerate-btn {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-copy-btn {
  background: #28a745;
  color: white;
}

.ai-copy-btn:hover {
  background: #218838;
  transform: translateY(-1px);
}

.ai-regenerate-btn {
  background: #6c757d;
  color: white;
}

.ai-regenerate-btn:hover {
  background: #5a6268;
  transform: translateY(-1px);
}

/* 弹窗底部 */
.ai-modal-footer {
  padding: 16px 24px;
  background: #f8f9fa;
  border-top: 1px solid #e9ecef;
}

.ai-modal-tips {
  text-align: center;
  color: #666;
  font-size: 12px;
  line-height: 1.4;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .ai-modal-container {
    width: 95%;
    max-height: 85vh;
    margin: 20px;
  }

  .ai-modal-header {
    padding: 16px 20px 12px;
  }

  .ai-modal-title {
    font-size: 16px;
  }

  .ai-modal-content {
    padding: 16px 20px;
  }

  .ai-response-content {
    padding: 16px;
  }

  .ai-response-actions {
    flex-direction: column;
  }

  .ai-copy-btn,
  .ai-regenerate-btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .ai-modal-container {
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    margin: 0;
  }

  .ai-modal-header {
    padding: 12px 16px 8px;
  }

  .ai-modal-content {
    padding: 12px 16px;
  }

  .ai-response-content {
    padding: 12px;
  }

  .ai-modal-footer {
    padding: 12px 16px;
  }
}

/* 滚动条样式 */
.ai-modal-content::-webkit-scrollbar {
  width: 6px;
}

.ai-modal-content::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.ai-modal-content::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.ai-modal-content::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}
